//
//  ShareViewController.m
//
//  Copyright 2012 Google Inc.
//
//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
//  use this file except in compliance with the License.  You may obtain a copy
//  of the License at
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
//  License for the specific language governing permissions and limitations under
//  the License.
//

#import "ShareViewController.h"

#import "GooglePlusShare.h"

@implementation ShareViewController

@synthesize name = _name;
@synthesize brand = _brand;
@synthesize nameText = _nameText;
@synthesize brandText = _brandText;
@synthesize url = _url;

static NSString * const kClientId = @"YOUR_CLIENT_ID";

// Set up the labels.
- (void)viewDidLoad {
  [super viewDidLoad];
  _name.text = _nameText;
  _brand.text = _brandText;
}

// Get the data from the preview view controller.
- (void) initUI:(NSString *)name withBrand:(NSString *)brand
         andURL:(NSString *)URL {
  _nameText = name;
  _brandText = brand;
  _url = URL;
}

// Share the selected product.
- (IBAction) didTapShare:(id)sender {
  GooglePlusShare *share = [[GooglePlusShare alloc] initWithClientID:kClientId];
  
  // Open the share dialog with the link attached, and some prespecified text.
  [[[[share shareDialog]
     setURLToShare:[NSURL URLWithString:_url]]
    setPrefillText:@"Check out this item I found!"] open];
}

@end
